import sys
from pathlib import Path

# Add the project root to the Python path
sys.path.append(str(Path(__file__).resolve().parent))

from database.db_connection import execute_query

def main():
    try:
        # 查询所有表
        tables = execute_query('SHOW TABLES')
        print("数据库中的表:")
        for table in tables:
            table_name = list(table.values())[0]
            print(f"- {table_name}")
            
            # 查询表结构
            columns = execute_query(f'DESCRIBE {table_name}')
            for column in columns:
                print(f"  - {column['Field']} ({column['Type']})")
            print()
            
    except Exception as e:
        print(f"查询数据库时出错: {e}")

if __name__ == "__main__":
    main() 